package cn.hnkjxy.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.hnkjxy.dao.UserDao;
import cn.hnkjxy.po.User;
import cn.hnkjxy.service.UserService;

@Service
@Transactional
public class UserServiceImpl implements UserService {
	@Autowired
	private UserDao userDao;

	public User findUser(String username, String password) {
		User user = this.userDao.findUser(username, password);
		return user;

	}

	@Override
	public Integer reviceUser(User user) {
		Integer ro = this.userDao.reviceUser(user);
		return ro;
	}

	@Override
	public User findUserById(Integer usid) {
		User user = this.userDao.findUserById(usid);
		return user;
	}

	public int addUser(String username, String password, String usertel, String gender, String role) {
		role = "普通会员";
		Integer row = this.userDao.addUser(username, password, usertel, gender, role);
		return row;
	}

	@Override
	public List<User> findAllUser() {
		List<User> users = this.userDao.findAllUser();
		return users;
	}

	@Override
	public Integer deleteUser(Integer usid) {
		Integer row = this.userDao.deleteUser(usid);
		return row;
	}

	@Override
	public List<User> findUserByCondition(User user) {
		List<User> users = this.userDao.findUserByCondition(user);
		return users;
	}

	@Override
	public Integer addUser2(User user) {
		String role = "普通会员";
		user.setRole(role);
		Integer row = this.userDao.addUser2(user);
		return row;
	}

	@Override
	public Integer findUserNameById(String username) {
		Integer usid = this.userDao.findUserNameById(username);
		return usid;
	}

	@Override
	public User findPassword(Integer usid) {
		return this.userDao.findPassword(usid);
	}

}
